package com.kiln.juxingqs.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.kiln.juxingqs.fragment.ZcjlOneFragment

class AvailableAssetsFragmentPageAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
    val fragments: Array<Fragment?> by lazy {
        arrayOfNulls(1)
    }

    override fun getItem(position: Int): Fragment {
        if (position == 0 && fragments[0] == null) {
            fragments[0] = ZcjlOneFragment()
        }
//        else if (position == 1 && fragments[1] == null) {
//            fragments[1] = ZcjlThreeFragment()
//        }
//        else if (position == 2 && fragments[2] == null) {
//            fragments[2] = ZcjlThreeFragment()
//        }
        return fragments[position]!!
    }

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        var title = ""
        if (position == 0 && fragments[0] == null) {
            title = "明细"
        }
//        else if (position == 1 && fragments[1] == null) {
//            title = "积分明细"
//        }
//        else if (position == 2 && fragments[2] == null) {
//            title = "DS明细"
//        }
        return title
    }
}